package Model;

/**
 * Classe modelo para os zumbis.
 * Todas as informacoes referente aos zumbis estao nesta classe.
 * 
 * @author Edjane Catolle, Igor Henrique, Luiz Augusto, Vladmir Chicarolli
 * @version 1.0.0
 * @since 05/31/2011
 */

import java.awt.Point;
import java.awt.Rectangle;
import java.util.List;
import java.util.Random;

public abstract class ZombieModel 
{
	public static ZombieModel _zombie = null;
	private Point position;
	private Rectangle rectZombie;
	private float speed;
	public int mType;
	public List<MapTile> myWay;
	
	public ZombieModel()
	{
		Random r = new Random();		
		int pos = r.nextInt(Map.MAPManager().getZombiesCanBorn().size() - 1);
		
		if(pos == 0)
		{
			pos++;
		}
		
		Rectangle rect = Map.MAPManager().getZombiesCanBorn().get(pos);
		this.position = new Point(rect.y, rect.x);		
		this.rectZombie = new Rectangle(this.position.x, this.position.y, 50, 50);
		myWay = Map.MAPManager().FindWayToSheeps(position);
		speed = GetSpeed();		
	}
	
	//Metodo para o abstract factory
	public abstract float GetSpeed();
	
	public void SetSpeed(float speed)
	{
		this.speed = speed;
	}
	
	public Point GetPosition()
	{
		return position;
	}
	
	public Rectangle GetRectZombie()
	{
		return rectZombie;
	}
	
	public MapTile GetNextStep()
	{
		if(myWay.size() == 0)
		{
			return null;
		}
		return myWay.get(myWay.size() - 1);
	}
	
	/**
	 * Controla o movimento do zumbi no eixo X
	 * @param direction - A direcao que o zumbi vai mover. ESQUERDA < 0 > DIREITA.
	 */
	public void MoveX(int direction)
	{
		this.position.x += direction * speed;
		this.rectZombie.x = this.position.x;
	}
	
	/**
	 * Controla o movimento do zumbi no eixo Y
	 * @param direction - A direcao que o zumbi vai mover. CIMA < 0 > BAIXO.
	 */
	public void MoveY(int direction)
	{
		this.position.y += direction * speed;
		this.rectZombie.y = this.position.y;
	}
}
